
package system.base;

import framework.core.*;

/*
	Author    :Wing
	CreateTime:2008-02-19 13:17:40
*/
public class ProductStorageSearchEvent extends SearchEvent
{

	private String m_id = "" ; // all

	private String m_warehouse_code = "" ; // all

	private String m_warehouse_name = "" ; // all

	private String m_position_code = "" ; // all

	private String m_position_name = "" ; // all

	private String m_product_id = "" ; // all

	private String m_product_code = "" ; // all

	private double m_product_count = Value.NULL_DOUBLE ; // all

	private double m_product_money = Value.NULL_DOUBLE ; // all

	private String m_status = "" ; // all

	private String m_create_user_id = "" ; // all

	private String m_create_user = "" ; // all

	private String m_create_time = "" ; // all

	private String m_last_update_user_id = "" ; // all

	private String m_last_update_user = "" ; // all

	private String m_last_update_time = "" ; // all

	private String m_is_sync = "" ; // all
	
	private String m_keeper_staff_id = "" ; // all
	private String isShow="0";//是否显示指定产品库存
	
	public static String showSql=" product_code in (select product_code from T_PRODUCT_SHARE_STOAGE) ";

public String getIsShow() {
		return isShow;
	}



	public void setIsShow(String isShow) {
		this.isShow = isShow;
	}



public ProductStorageSearchEvent() 
{
	super();
	
	setOrderField(ProductStorage.ID);
		
}



	public String getId()
	{
		return m_id ;
	}
	public void setId(String v)
	{
		m_id = v;
	}

	public String getWarehouseCode()
	{
		return m_warehouse_code ;
	}
	public void setWarehouseCode(String v)
	{
		m_warehouse_code = v;
	}

	public String getWarehouseName()
	{
		return m_warehouse_name ;
	}
	public void setWarehouseName(String v)
	{
		m_warehouse_name = v;
	}

	public String getPositionCode()
	{
		return m_position_code ;
	}
	public void setPositionCode(String v)
	{
		m_position_code = v;
	}

	public String getPositionName()
	{
		return m_position_name ;
	}
	public void setPositionName(String v)
	{
		m_position_name = v;
	}

	public String getProductId()
	{
		return m_product_id ;
	}
	public void setProductId(String v)
	{
		m_product_id = v;
	}

	public String getProductCode()
	{
		return m_product_code ;
	}
	public void setProductCode(String v)
	{
		m_product_code = v;
	}

	public double getProductCount()
	{
		return m_product_count ;
	}
	public void setProductCount(double v)
	{
		m_product_count = v;
	}

	public double getProductMoney()
	{
		return m_product_money ;
	}
	public void setProductMoney(double v)
	{
		m_product_money = v;
	}

	public String getStatus()
	{
		return m_status ;
	}
	public void setStatus(String v)
	{
		m_status = v;
	}

	public String getCreateUserId()
	{
		return m_create_user_id ;
	}
	public void setCreateUserId(String v)
	{
		m_create_user_id = v;
	}

	public String getCreateUser()
	{
		return m_create_user ;
	}
	public void setCreateUser(String v)
	{
		m_create_user = v;
	}

	public String getCreateTime()
	{
		return m_create_time ;
	}
	public void setCreateTime(String v)
	{
		m_create_time = v;
	}

	public String getLastUpdateUserId()
	{
		return m_last_update_user_id ;
	}
	public void setLastUpdateUserId(String v)
	{
		m_last_update_user_id = v;
	}

	public String getLastUpdateUser()
	{
		return m_last_update_user ;
	}
	public void setLastUpdateUser(String v)
	{
		m_last_update_user = v;
	}

	public String getLastUpdateTime()
	{
		return m_last_update_time ;
	}
	public void setLastUpdateTime(String v)
	{
		m_last_update_time = v;
	}

	public String getIsSync()
	{
		return m_is_sync ;
	}
	public void setIsSync(String v)
	{
		m_is_sync = v;
	}
		



	public String viewId() throws Exception
	{
		return Value.view(getId());
	}

	public String viewWarehouseCode() throws Exception
	{
		return Value.view(getWarehouseCode());
	}

	public String viewWarehouseName() throws Exception
	{
		return Value.view(getWarehouseName());
	}

	public String viewPositionCode() throws Exception
	{
		return Value.view(getPositionCode());
	}

	public String viewPositionName() throws Exception
	{
		return Value.view(getPositionName());
	}

	public String viewProductId() throws Exception
	{
		return Value.view(getProductId());
	}

	public String viewProductCode() throws Exception
	{
		return Value.view(getProductCode());
	}

	public String viewProductCount() throws Exception
	{
		return Value.view(getProductCount());
	}

	public String viewProductMoney() throws Exception
	{
		return Value.view(getProductMoney());
	}

	public String viewStatus() throws Exception
	{
		return Value.view(getStatus());
	}

	public String viewCreateUserId() throws Exception
	{
		return Value.view(getCreateUserId());
	}

	public String viewCreateUser() throws Exception
	{
		return Value.view(getCreateUser());
	}

	public String viewCreateTime() throws Exception
	{
		return Value.view(getCreateTime());
	}

	public String viewLastUpdateUserId() throws Exception
	{
		return Value.view(getLastUpdateUserId());
	}

	public String viewLastUpdateUser() throws Exception
	{
		return Value.view(getLastUpdateUser());
	}

	public String viewLastUpdateTime() throws Exception
	{
		return Value.view(getLastUpdateTime());
	}

	public String viewIsSync() throws Exception
	{
		return Value.view(getIsSync());
	}


	public Conditions toConditions() throws Exception
	{
		Conditions c = super.toConditions();

	c.add(getCondition(ProductStorage.ID,getId()));

	c.add(getCondition(ProductStorage.WAREHOUSE_CODE,getWarehouseCode()));

	c.add(getCondition(ProductStorage.WAREHOUSE_NAME,getWarehouseName()));

	c.add(getCondition(ProductStorage.POSITION_CODE,getPositionCode()));

	c.add(getCondition(ProductStorage.POSITION_NAME,getPositionName()));

	c.add(getCondition(ProductStorage.PRODUCT_ID,getProductId()));

	c.add(getCondition(ProductStorage.PRODUCT_CODE,getProductCode()));

	c.add(getCondition(ProductStorage.PRODUCT_COUNT,getProductCount()));

	c.add(getCondition(ProductStorage.PRODUCT_MONEY,getProductMoney()));

	c.add(getCondition(ProductStorage.STATUS,getStatus()));

	c.add(getCondition(ProductStorage.CREATE_USER_ID,getCreateUserId()));

	c.add(getCondition(ProductStorage.CREATE_USER,getCreateUser()));

	c.add(getCondition(ProductStorage.CREATE_TIME,getCreateTime()));

	c.add(getCondition(ProductStorage.LAST_UPDATE_USER_ID,getLastUpdateUserId()));

	c.add(getCondition(ProductStorage.LAST_UPDATE_USER,getLastUpdateUser()));

	c.add(getCondition(ProductStorage.LAST_UPDATE_TIME,getLastUpdateTime()));

	c.add(getCondition(ProductStorage.IS_SYNC,getIsSync()));
		
	if(getIsShow().equals("1")){//显示指定的手腕
		c.add(showSql);
	}
	//add by Wing start
	if (getWarehouseCodes() != null) {
	    c.add(ProductStorage.WAREHOUSE_CODE,Conditions.IN,getWarehouseCodes());
	}

	if (!getProductName().equalsIgnoreCase("")) {
	    c.add(ProductStorage.PRODUCT_CODE + " in (select CONCENTRICITY_CODE from t_product where name like ?)",Conditions.CUSTOM, "%" + getProductName() + "%");
	}
	
    if (!getKeyWord().equalsIgnoreCase(""))
    {
        String[] keyWord = new String[7];
        keyWord[0] = "%" + getKeyWord() + "%";
        keyWord[1] = "%" + getKeyWord() + "%";
        keyWord[2] = "%" + getKeyWord() + "%";
        keyWord[3] = "%" + getKeyWord() + "%";
        keyWord[4] = "%" + getKeyWord() + "%";
        keyWord[5] = "%" + getKeyWord() + "%";
        keyWord[6] = "%" + getKeyWord() + "%";
        
        c.add(ProductStorage.PRODUCT_CODE + " in (select CONCENTRICITY_CODE from t_product where NAME like ? or CONCENTRICITY_CODE like ? or MODEL like ? " +
              "or SPEC like ? or PRODUCT_BRAND like ? or MANUFATURER like ? or APPENDER_PROPERTY like ? )",Conditions.CUSTOM,keyWord); 
    }
    
    if (!getProviderName().equalsIgnoreCase("")) {
        c.add(ProductStorage.PROVIDER_CODE + " in (select b.code from t_product a,t_provider b where a.provider_code = b.code and b.name = ?)",Conditions.CUSTOM,getProviderName());
    }
    
    if (getIsIncludeZeroStorage() != null && !getIsIncludeZeroStorage().equalsIgnoreCase("") ) {
        c.add(ProductStorage.PRODUCT_COUNT + " >= ?",Conditions.CUSTOM,m_zero_storage);
    } else {
        c.add(ProductStorage.PRODUCT_COUNT + " > ?",Conditions.CUSTOM,m_zero_storage);
    }
    
    if (!getIsNormal().equalsIgnoreCase("")) {
        c.add(ProductStorage.PRODUCT_CODE + " in (select CONCENTRICITY_CODE from t_product where is_normal = ?)",Conditions.CUSTOM,getIsNormal());
    }
	
    if (!getDullStorage().equalsIgnoreCase("")) {
        DateUtil dateUtil = new DateUtil();
        String dates = "";
        if (getDullStorage().equals(ConstDefine.DULL_STORAGE_TIME_60)){
            dateUtil.advanceDays(-60+1);
            dates = dateUtil.getFullString();
        } else if (getDullStorage().equals(ConstDefine.DULL_STORAGE_TIME_90)) {
            dateUtil.advanceDays(-90+1);
            dates = dateUtil.getFullString();
        } else if (getDullStorage().equals(ConstDefine.DULL_STORAGE_TIME_180)){
            dateUtil.advanceDays(-180+1);
            dates = dateUtil.getFullString();
        }
        c.add(" product_count > 0 and last_update_time <= ?",Conditions.CUSTOM,dates);
    }
    
    if (!getBalanceMode().equalsIgnoreCase("")) {
    	c.add(getCondition(ProductStorage.BALANCE_MODE,getBalanceMode()));
    }
    
    if (!getStartLastUpdate().equalsIgnoreCase("")) {
        c.add(" last_update_time >= ?",Conditions.CUSTOM,getStartLastUpdate()+" 00:00:00");
    }
    
    if (!getEndLastUpdate().equalsIgnoreCase("")) {
        c.add(" last_update_time <= ?",Conditions.CUSTOM,getEndLastUpdate()+" 23:59:60");
    }
    
    if(!getKeeperStaffId().equalsIgnoreCase("")){
    	c.add(ProductStorage.PRODUCT_ID + " in ( select product_id from t_warehouse_product where keeper_staff_id = '"+getKeeperStaffId()+"') ");
    }
    //add by Wing end
    
    c.add(ProductStorage.WAREHOUSE_CODE,Conditions.LIKE,getWarehouseCodeUser()+"%");
			
		return c ;
	}
	
//add by Wing start
	private String []m_warehouse_codes;
    public String []getWarehouseCodes()
    {
        return m_warehouse_codes ;
    }
    public void setWarehouseCodes(String []warehouseCodes)
    {
        m_warehouse_codes = warehouseCodes;
    }
    
    private String m_product_name = "";
    public String getProductName()
    {
        return this.m_product_name;
    }
    public void setProductName(String productName)
    {
        this.m_product_name = productName;
    }
    
    private String m_key_word = "";
    public String getKeyWord()
    {
        return m_key_word;
    }
    public void setKeyWord(String keyWord)
    {
        m_key_word = keyWord;
    }
    public String viewKeyWord() throws Exception
    {
        return Value.view(getKeyWord());
    }
    
    private String m_provider_name = "";
    public String getProviderName() {
        return this.m_provider_name;
    }
    public void setProviderName(String providerName) {
        this.m_provider_name = providerName;
    }
    
    private String m_isIncludeZeroStorage = "";
    private double m_zero_storage = 0;
    public String getIsIncludeZeroStorage() {
        return this.m_isIncludeZeroStorage;
    }
    public void setIsIncludeZeroStorage(String isIncludeZeroStorage) {
        this.m_isIncludeZeroStorage = isIncludeZeroStorage;
    }
    
    private String m_is_normal = "";
    public String getIsNormal() {
        return this.m_is_normal;
    }
    public void setIsNormal(String isNormal) {
        this.m_is_normal = isNormal;
    }
    
    private String m_dull_storage = "";
    public String getDullStorage() {
        return this.m_dull_storage;
    }
    public void setDullStorage(String dullStorage) {
        this.m_dull_storage = dullStorage;
    }
    
    private String m_balance_mode = "";
    public String getBalanceMode() {
        return this.m_balance_mode;
    }
    public void setBalanceMode(String balanceMode) {
        this.m_balance_mode = balanceMode;
    }
    
    private String m_start_lastUpdate = "";
    public String getStartLastUpdate() {
        return this.m_start_lastUpdate;
    }
    public void setStartLastUpdate(String startUpdate) {
        this.m_start_lastUpdate = startUpdate;
    }
    
    private String m_end_lastUpdate = "";
    public String getEndLastUpdate() {
        return this.m_end_lastUpdate;
    }
    public void setEndLastUpdate(String endUpdate) {
        this.m_end_lastUpdate = endUpdate;
    }
    
//add by Wing end
  
  //add by Jackey start    
    private String m_warehouse_code_user = "" ; // all
    public String getWarehouseCodeUser()
    {
        return m_warehouse_code_user ;
    }
    public void setWarehouseCodeUser(String v)
    {
        m_warehouse_code_user = v;
    }
    public String viewWarehouseCodeUser() throws Exception
    {
        return Value.view(getWarehouseCodeUser());
    }
  //add by Jackey end
    
    private String[] m_warehouse_tree_codes;
    public String[] getWarehouseTreeCodes(){
    	return m_warehouse_tree_codes;
    }
    
    public void setWarehouseTreeCodes(String[] warehouseTreeCodes){
    	m_warehouse_tree_codes = warehouseTreeCodes;
    }
    
	public String getKeeperStaffId()
	{
		return m_keeper_staff_id ;
	}
	public void setKeeperStaffId(String v)
	{
		m_keeper_staff_id = v;
	}
}
